function HandleTableRowProduceMailing(gui, item, options) {
  this._gui = gui;
  this._item = item;
  this._options = options;
  this._popupBox = new PopupBox();
  this._popupBox2 = new PopupBox2();
  
  this._user = (options && options.user) ? options.user : null;
  this._date = (options && options.date) ? options.date : null;
  this._produces = (options && options.produces) ? options.produces : [];
  this._callbackFunc = (options && options.callbackFunc) ? options.callbackFunc : function() {};
  
  this._createElements();
};

HandleTableRowProduceMailing.prototype._createElements = function() {
  var options, model, state, transitions = [], a, checkbox, _self = this;
  
  this._gui.customer.appendChild(document.createTextNode((this._item.customerId != 0) ? this._item.branch + DlmanageUtils.customerId(this._item.customerId) : 'Parcel'));
  if (this._item.customerId == 0) {
    this._gui.customer.style.fontWeight = 'bold';
  }
  
  this._gui.name.appendChild(document.createTextNode(this._item.title));
  
  if (this._item.cancelled == 0) {
    var note = document.createElement('img');
    note.src = (this._item.v2_notes.length != 0) ? 'images/buttons/note_hilight.png' : 'images/buttons/note.png';
    note.style.cursor = 'pointer';
    note.style.margin = '0 0 0 5px';
    note._produce = this._item;
    note.onclick = function() { var div, pos, func1, func2;
                                var pro = this._produce;
                                div = document.createElement('div');
                                MiscUtils.dialog(_self._popupBox2,  DOMUtils.findPos(this), div, null, null, {t: pro.title, width: 760, height: 100});
                                new DialogProduceNote(div, pro, { author: _self._user, now: _self._date, isProduce: true, popupBox: _self._popupBox2, callbackFunc: function() { _self._callbackFunc();} });
                                return false;
                              };
    this._gui.name.appendChild(note);
  }
  
  if (this._item.pi_selects.length > 0 && (this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_4X6|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_RETOUCH|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_COMMON|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_PRODUCT_RETOUCH_MAGAZINE|escape:javascript}}' ||
      this._item.pi_model == '{{$smarty.const.MODEL_NAME_ALBUM_DESIGN|escape:javascript}}')) {
    a = document.createElement('a');
    a.style.margin = '0 0 0 5px';
    a.href = '#';
    a.appendChild(document.createTextNode('Info'));
    a.onclick = function() { var func1 = function() { _self._popupBox2._close(); };
                             var div = document.createElement('div');
                             MiscUtils.dialog(_self._popupBox2, DOMUtils.findPos(this), div, func1, null, {t: _self._item.pi_name, width: 520, height: 100});
                             new DialogDetails(div, _self._item, { orderId: _self._item.orderId, hidePrice: _self._options.hidePrice });
                             return false;
                           };
    this._gui.name.appendChild(a);
  }
  this._gui.user.appendChild(document.createTextNode(this._item.user_account));
  
  model = Manage.map()[this._item.pi_model];
  for (var i = 0, il = model.states.length; i < il; i++) {
    var s = model.states[i];
    if (this._item.state == s.id) {
      state = s;
      break;
    }
  }
  
  for (var i = 0, il = model.transitions.length; i < il; i++) {
    var t = model.transitions[i];
    if (this._item.state == t.source.id) {
      transitions[transitions.length] = t;
    }
  }
  
  options = MiscUtils.clone(this._options);
  options.transitions = transitions;
  options.callbackFunc = function() { _self._popupBox._close();
                                      _self._callbackFunc();
                                    };
  
  this._gui.task.appendChild(document.createTextNode(state.title));
  
//  if (this._item.events.length > 0) {
    a = document.createElement('a');
    a.style.margin = '0 0 0 5px';
    a.href = '#';
    a.appendChild(document.createTextNode('Log'));
    a.onclick = function() { var func1 = function() { _self._popupBox2._close(); };
                             var div = document.createElement('div');
                             MiscUtils.dialog(_self._popupBox2, DOMUtils.findPos(this), div, func1, null, {t: _self._item.title, width: 820, height: 100});
                             new DialogHistory(div, _self._item, options);
                             return false;
                           };
    this._gui.task.appendChild(a);
//  }
    
  this._gui.dateline.style.color = (this._item.deadline && ((SimpleDate.toStamp(this._item.deadline) - SimpleDate.toStamp(this._date)) / 86400) < 0) ? '#ff0000' : '#000000';
  this._gui.dateline.appendChild(document.createTextNode((this._item.deadline) ? (((((SimpleDate.toStamp(this._item.deadline) - SimpleDate.toStamp(this._date)) / 86400) <= -1) || (((SimpleDate.toStamp(this._item.deadline) - SimpleDate.toStamp(this._date)) / 86400) >= 0)) ? parseInt((SimpleDate.toStamp(this._item.deadline) - SimpleDate.toStamp(this._date)) / 86400, 10) : '-1') : ''));

  checkbox = DOMUtils.createInput(null, null, 'checkbox', null, null);
  
  var exist = false;
  for (var i = 0, il = this._produces.length; i < il; i++) {
    var p = this._produces[i];
    if (p == this._item) {
      exist = true;
    }
  }
  checkbox.defaultChecked = exist;
  checkbox.onclick = function() { if (this.checked) {
                                    _self._produces[_self._produces.length] = _self._item;
                                  } else {
                                    MiscUtils.remove(_self._produces, _self._item);
                                  }
                                };
  this._gui.progress.appendChild(checkbox);
};